from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.views import admins
from meiduo_admin.views import brands
from meiduo_admin.views import channels
from meiduo_admin.views import groups
from meiduo_admin.views import options
from meiduo_admin.views import permissions
from meiduo_admin.views import images
from meiduo_admin.views import orders
from meiduo_admin.views import skus
from meiduo_admin.views import specs
from meiduo_admin.views import spus
from meiduo_admin.views import statistical
from meiduo_admin.views import users

urlpatterns = [
    # 使用JWT完成登陆操作
    url(r'^authorizations/$', obtain_jwt_token),
    # -----------------------数据统计-----------------------
    # 用户总量统计
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 日增用户统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 日活跃用户统计
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),
    # 日下单用户量统计
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    # 月增用户统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 日分类商品访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),

    # ------------------------用户管理-----------------------
    # 获取查询用户
    url(r'^users/$', users.UserView.as_view()),
    # ---------------商品规格--spu简单商品信息-----------------------
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    # ---------------商品图片--sku简单商品信息-----------------------
    url(r'^skus/simple/$', images.ImagesView.as_view({'get': 'simple'})),
    # ---------------商品SKU--------------------------------------
    # 获取商品规格信息
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUGoodsView.as_view({'get': 'specs'})),
    # ----------获取权限类型-----------
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_types'})),
    # ----------获取权限简单信息----------
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),
    # ----------获取分组的简单信息----------
    url(r'^permission/groups/simple/$', admins.AdminView.as_view({'get': 'simple'})),
    # ----------获取规格选项的类型----------
    url(r'^goods/specs/simple/$', options.OptionsView.as_view({'get': 'simple'})),
    # 频道管理
    # ----------获取频道组信息-----------
    url(r'^goods/channel_types/$', channels.ChannelsView.as_view({'get': 'channel_types'})),
    # ----------获取一级分类信息-----------
    url(r'^goods/categories/$', channels.ChannelsView.as_view({'get': 'category'})),
    # spu管理
    # ----------获取品牌信息------------
    url(r'^goods/brands/simple/$', spus.SPUView.as_view({'get': 'simple'})),
    # ----------获取一二三级分类---------
    # 一级分类
    url(r'^goods/channel/categories/$', spus.SPUView.as_view({'get': 'category'})),
    # 二三级分类
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SPUView.as_view({'get': 'category1'})),

]

# 商品规格的增删改查
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='specs')
urlpatterns += router.urls

# 频道管理
router = DefaultRouter()
router.register('goods/channels', channels.ChannelsView, base_name='channels')
urlpatterns += router.urls

# 品牌管理
router = DefaultRouter()
router.register('goods/brands', brands.BrandsView, base_name='brands')
urlpatterns += router.urls

# 商品图片的增删改查
router = DefaultRouter()
router.register('skus/images', images.ImagesView, base_name='images')
urlpatterns += router.urls

# 商品sku表管理
router = DefaultRouter()
router.register('skus', skus.SKUGoodsView, base_name='skus')
urlpatterns += router.urls

# 订单管理
router = DefaultRouter()
router.register('orders', orders.OrdersView, base_name='orders')
urlpatterns += router.urls

# 权限
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionView, base_name='perms')
urlpatterns += router.urls

# 用户组
router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls

# 管理员
router = DefaultRouter()
router.register('permission/admins', admins.AdminView, base_name='admins')
urlpatterns += router.urls

# 商品spu表管理
router = DefaultRouter()
router.register('goods', spus.SPUView, base_name='spus')
urlpatterns += router.urls

# 规格选项管理
router = DefaultRouter()
router.register('specs/options', options.OptionsView, base_name='options')
urlpatterns += router.urls
